#ifndef USEIO_H
#define USEIO_H

//===============================================
// First Motor Controller
//===============================================

#define OUT_BASE1		64
#define IN_BASE1		0x00		
#define	OUT_EX1			0x100
#define IN_EX1			0x200

//===============================================
// Second Motor Controller
//===============================================

#define	OUT_BASE2		0x20
#define	IN_BASE2		0x20	
#define OUT_EX2			0x300
#define IN_EX2			0x400

#define IO_END_NO       0x500
#define OUT_NO			0x100
#define IN_NO			0x00
//======================== I/O define format ==============================
//-----------------------------------------------------------------------------
/////////////////////////////    INPUT   //////////////////////////////////////
//-----------------------------------------------------------------------------
// INPUT DEFINE (IO_NO X020 ~ X02F)
#define X_START_SWITCH					(IN_EX1 + 0x00)
#define X_STOP_SWITCH					(IN_EX1 + 0x01)
#define X_SERVO_ON_SWITCH				(IN_EX1 + 0x02)
#define X_HOME_SWITCH					(IN_EX1 + 0x03)
#define X_E_STOP_SW_1					(IN_EX1 + 0x04)
#define X_DOOR1_OPEN					(IN_EX1 + 0x05)
#define X_DOOR2_OPEN					(IN_EX1 + 0x06)
#define X_MAIN_AIR_CHECK				(IN_EX1 + 0x07)

#define X_MAIN_NITROGEN_CHECK			(IN_EX1 + 0x08)
#define	X_DOOR_UNLOCK					(IN_EX1 + 0x09)
#define	X_GRIPPER_CYL_UP				(IN_EX1 + 0x0A)
#define	X_GRIPPER_CYL_DOWN				(IN_EX1 + 0x0B)
#define X_EV_SHUTTER_OPEN				(IN_EX1 + 0x0C)
#define X_EV_SHUTTER_CLOSE				(IN_EX1 + 0x0D)
#define X_EV_SAFETY_SENSOR				(IN_EX1 + 0x0E)
#define X_TRANSFER_OVERLOAD				(IN_EX1 + 0x0F)
//-----------------------------------------------------------------------------
// INPUT DEFINE (IO_NO X030 ~ X03F) //loader Port
//-----------------------------------------------------------------------------
#define X_8INCH_RING_CHECK				(IN_EX1 + 0x10)
#define X_WAFER_LINE_CHECK				(IN_EX1 + 0x11)
#define X_HIGH_12INCH_SENSOR			(IN_EX1 + 0x12)
#define X_HIGH_8INCH_SENSOR				(IN_EX1 + 0x13)
#define X_LOW_12INCH_SENSOR				(IN_EX1 + 0x14)
#define X_LOW_8INCH_SENSOR				(IN_EX1 + 0x15)
#define X_OHT_MAGAZINE_SENSOR			(IN_EX1 + 0x16)
#define X_UV_SHUTTER_OPEN				(IN_EX1 + 0x17)

#define X_UV_SHUTTER_CLOSE				(IN_EX1 + 0x18)
#define X_WAFER_TABLE_CHECK				(IN_EX1 + 0x19)
#define	X_E_STOP_SW_2					(IN_EX1 + 0x1A)
#define X_TRANS_OVERLOAD				(IN_EX1 + 0x1B)  
#define X_TRANS_OVERHEAT				(IN_EX1 + 0x1C)
#define X_INVERTER_ERROR				(IN_EX1 + 0x1D)
#define X_UV_TEMP_UP_LIMET	 			(IN_EX1 + 0x1E)
#define X_UV_TEMP_DOWN_LIMET			(IN_EX1 + 0x1F)
//-----------------------------------------------------------------------------
// INPUT DEFINE (IO_NO X040 ~ X04F) //
//-----------------------------------------------------------------------------
#define X_EX_CYL_UP 					(IN_EX1 + 0x20)
#define X_EX_CYL_DOWN					(IN_EX1 + 0x21)
#define X_UPPER_LOADER_FOR				(IN_EX1 + 0x22)
#define X_UPPER_LOADER_BACK 			(IN_EX1 + 0x23)
#define X_LOWER_LOADER_FOR				(IN_EX1 + 0x24)
#define	X_LOWER_LOADER_BACK				(IN_EX1 + 0x25)
#define	X_AGV_SHUTTER_OPEN				(IN_EX1 + 0x26)
#define	X_AGV_SHUTTER_CLOSE				(IN_EX1 + 0x27)

#define	X_PIO_INPUT_1						(IN_EX1 + 0x28)
#define	X_PIO_INPUT_2						(IN_EX1 + 0x29)
#define	X_PIO_INPUT_3						(IN_EX1 + 0x2A)
#define	X_PIO_INPUT_4						(IN_EX1 + 0x2B)
#define X_PIO_INPUT_5 					(IN_EX1 + 0x2C)
#define	X_PIO_INPUT_6						(IN_EX1 + 0x2D)
#define X_PIO_INPUT_7 					(IN_EX1 + 0x2E)
#define X_PIO_INPUT_8						(IN_EX1 + 0x2F)
//-----------------------------------------------------------------------------
// INPUT DEFINE (IO_NO X050 ~ X05F) //
//-----------------------------------------------------------------------------
#define X_AGV_SAFETY_SENSOR 			(IN_EX1 + 0x30)
#define X_SPARE_31 						(IN_EX1 + 0x31)
#define X_MODLE_F12_SET 						(IN_EX1 + 0x32)
#define X_MODEL_F8_SET 						(IN_EX1 + 0x33)
#define X_MODEL_B8_SET					(IN_EX1 + 0x34)
#define	X_MODEL_B12_SET						(IN_EX1 + 0x35)
#define	X_12INCH_RING_CHECK						(IN_EX1 + 0x36)
#define	X_SPARE_37						(IN_EX1 + 0x37)

#define	X_OHT_LOADER_FOR 						(IN_EX1 + 0x38)
#define	X_OHT_LOADER_BACK						(IN_EX1 + 0x39)
#define	X_SPARE_3A 						(IN_EX1 + 0x3A)
#define	X_SPARE_3B						(IN_EX1 + 0x3B)
#define X_SPARE_3C 						(IN_EX1 + 0x3C)
#define	X_SPARE_3D						(IN_EX1 + 0x3D)
#define X_SPARE_3E 						(IN_EX1 + 0x3E)
#define X_SPARE_3F						(IN_EX1 + 0x3F)
//-----------------------------------------------------------------------------
//////////////////////////////  OUTPUT   //////////////////////////////////////
//-----------------------------------------------------------------------------
// OUTPUT DEFINE (IO_NO  Y020 ~ Y02F)
//-----------------------------------------------------------------------------
#define Y_UV_SHUTTER_CLOSE				(OUT_EX1 + 0x00)
#define Y_UV_SHUTTER_OPEN				(OUT_EX1 + 0x01)
#define Y_EV_SHUTTER_OPEN 				(OUT_EX1 + 0x02)
#define Y_EV_SHUTTER_CLOSE  			(OUT_EX1 + 0x03)
#define Y_GRIPPER_SOL 					(OUT_EX1 + 0x04)
#define Y_NITROGEN_SOL					(OUT_EX1 + 0x05)
#define Y_EX_CYL_UP						(OUT_EX1 + 0x06)
#define Y_EX_CYL_DOWN					(OUT_EX1 + 0x07)

#define Y_SPARE_08						(OUT_EX1 + 0x08)
#define Y_BZ_K1							(OUT_EX1 + 0x09)
#define	Y_BZ_K2							(OUT_EX1 + 0x0A)
#define Y_DOOR_UNLOCK					(OUT_EX1 + 0x0B)
#define Y_TOWER_LAMP_G					(OUT_EX1 + 0x0C)
#define Y_TOWER_LAMP_Y					(OUT_EX1 + 0x0D)
#define Y_TOWER_LAMP_R					(OUT_EX1 + 0x0E)
#define Y_UV_POWER						(OUT_EX1 + 0x0F)
//-------------------------------------------------------------------------------		
// OUTPUT DEFINE (IO_NO  Y030 ~ Y03F)
//-------------------------------------------------------------------------------

#define Y_UPPER_LOADER_FOR							(OUT_EX1 + 0x10)
#define Y_UPPER_LOADER_BACK 						(OUT_EX1 + 0x11)
#define	Y_LOWER_LOADER_FOR							(OUT_EX1 + 0x12)
#define	Y_LOWER_LOADER_BACK							(OUT_EX1 + 0x13)
#define	Y_AGV_SHUTTER_OPEN							(OUT_EX1 + 0x14)
#define	Y_AGV_SHUTTER_CLOSE							(OUT_EX1 + 0x15)
#define	Y_WAFER_CENTERING_FOR_BACK						(OUT_EX1 + 0x16)
#define	Y_SPARE_17						(OUT_EX1 + 0x17)

#define Y_START_LAMP						(OUT_EX1 + 0x18)
#define	Y_STOP_LAMP						(OUT_EX1 + 0x19)			
#define	Y_SPARE_1A						(OUT_EX1 + 0x1A)		
#define Y_HOME_LAMP						(OUT_EX1 + 0x1B)		
#define Y_SPARE_1C						(OUT_EX1 + 0x1C)		
#define	Y_IONIZER						(OUT_EX1 + 0x1D)		
#define	Y_FAN_BLOW_OUT						(OUT_EX1 + 0x1E)		
#define	Y_FAN_BLOW_IN						(OUT_EX1 + 0x1F)

//-----------------------------------------------------------------------------
// OUTPUT DEFINE (IO_NO  Y040 ~ Y04F)
//-----------------------------------------------------------------------------

#define Y_PIO_OUTPUT_1			(OUT_EX1 + 0x20)
#define Y_PIO_OUTPUT_2			(OUT_EX1 + 0x21)		
#define Y_PIO_OUTPUT_3			(OUT_EX1 + 0x22)	
#define Y_PIO_OUTPUT_4			(OUT_EX1 + 0x23)	
#define Y_PIO_OUTPUT_5			(OUT_EX1 + 0x24)	
#define Y_PIO_OUTPUT_6			(OUT_EX1 + 0x25)	
#define Y_PIO_OUTPUT_7			(OUT_EX1 + 0x26)
#define Y_PIO_OUTPUT_8			(OUT_EX1 + 0x27)

#define Y_OHT_LOADER_FOR		(OUT_EX1 + 0x28)
#define Y_OHT_LOADER_BACK		(OUT_EX1 + 0x29)
#define Y_SPARE_2A		(OUT_EX1 + 0x2A)
#define Y_SPARE_2B		(OUT_EX1 + 0x2B)
#define Y_SPARE_2C		(OUT_EX1 + 0x2C)
#define Y_SPARE_2D		(OUT_EX1 + 0x2D)
#define Y_SPARE_2E		(OUT_EX1 + 0x2E)
#define Y_SPARE_2F		(OUT_EX1 + 0x2F)
//-----------------------------------------------------------------------------
// OUTPUT DEFINE (IO_NO  Y050 ~ Y05F)
//-----------------------------------------------------------------------------
#define Y_SPARE_30		(OUT_EX1 + 0x30)
#define Y_SPARE_31		(OUT_EX1 + 0x31)
#define Y_SPARE_32		(OUT_EX1 + 0x32)
#define Y_SPARE_33		(OUT_EX1 + 0x33)
#define Y_SPARE_34		(OUT_EX1 + 0x34)
#define	Y_SPARE_35		(OUT_EX1 + 0x35)
#define	Y_SPARE_36		(OUT_EX1 + 0x36)
#define Y_SPARE_37		(OUT_EX1 + 0x37)

#define Y_SPARE_38		(OUT_EX1 + 0x38)
#define Y_SPARE_39		(OUT_EX1 + 0x39)			
#define Y_SPARE_3A		(OUT_EX1 + 0x3A)		
#define Y_SPARE_3B		(OUT_EX1 + 0x3B)		
#define Y_SPARE_3C		(OUT_EX1 + 0x3C)		
#define Y_SPARE_3D		(OUT_EX1 + 0x3D)		
#define Y_SPARE_3E		(OUT_EX1 + 0x3E)		
#define Y_SPARE_3F		(OUT_EX1 + 0x3F)
///////////////////////////////////////////////////////////////////
#endif
